﻿using SW.Lite.IDAL.Master;
using SW.Lite.Infrastructure.Common;
using SW.Lite.Infrastructure.Service;
using SW.Lite.Model.Master;

namespace SW.Lite.BLL.Master
{
    public class Button
    {
        private static readonly IButton Dal = ServiceLocator.Instance.GetInstance<IButton>("Master.Button");

        /// <summary>
        ///     数据是否存在
        /// </summary>
        /// <param name="id"></param>
        public static bool Exists(int id)
        {
            return Dal.Exists(id);
        }

        /// <summary>
        ///     获取单个项
        /// </summary>
        /// <param name="id"></param>
        public static ButtonModel Single(int id)
        {
            return Dal.Single(id);
        }

        /// <summary>
        ///     获取所有项目
        /// </summary>
        public static PageList<ButtonModel> All()
        {
            return Dal.All();
        }

        /// <summary>
        ///     根据菜单ID获取按钮列表
        /// </summary>
        /// <param name="menuId">菜单ID</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页大小</param>
        public static PageList<ButtonModel> All(int menuId, int pageIndex, int pageSize)
        {
            return Dal.All(menuId, pageIndex, pageSize);
        }

        /// <summary>
        ///     插入数据
        /// </summary>
        /// <param name="model">单个项</param>
        public static ExecuteResult Insert(ButtonModel model)
        {
            return Dal.Insert(model);
        }

        /// <summary>
        ///     更新数据
        /// </summary>
        /// <param name="model">单个项</param>
        public static ExecuteResult Update(ButtonModel model)
        {
            return Dal.Update(model);
        }

        /// <summary>
        ///     删除数据
        /// </summary>
        /// <param name="id"></param>
        public static ExecuteResult Delete(int id)
        {
            return Dal.Delete(id);
        }

        /// <summary>
        ///     根据角色ID集合获取按钮列表
        /// </summary>
        /// <param name="roleIds">角色ID集合</param>
        public static PageList<ButtonModel> GetButtonsByRoleIds(params int[] roleIds)
        {
            return Dal.GetButtonsByRoleIds(roleIds);
        }

        /// <summary>
        ///     根据菜单ID获取按钮列表
        /// </summary>
        /// <param name="menuId">菜单ID</param>
        public static PageList<ButtonModel> GetButtonsByMenuId(int menuId)
        {
            return Dal.GetButtonsByMenuId(menuId);
        }
    }
}